package genetic.q1.functions;

public class ListVariable extends Variable{

	Variable ref;
	int[] list;
	
	public ListVariable(String name, Variable ref) {
		super(name);
		this.ref = ref;
	}
	
	@Override
	public void init(int[] list) {
		this.list = list;
	}
	
	@Override
	public int getValue() {
		return list[ref.getValue() % list.length];
	}
	
	@Override
	public String toString() {
		return name + "[" +ref.toString() +"]";
	}

}
